import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Ip,
} from '@nestjs/common';
import { CodeService } from './code.service';
import { CreateCodeDto } from './dto/create-code.dto';
import { UpdateCodeDto } from './dto/update-code.dto';
import { ApiBody, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { responseCactchaCode } from './entities/Response';

@Controller('code')
export class CodeController {
  constructor(private readonly codeService: CodeService) {}

  //设置图形验证码
  @ApiOperation({ summary: '图形验证码接口' })
  @ApiResponse({
    status: 200,
    description: '图形验证码获取成功',
    type: responseCactchaCode,
  })
  @Get('setCode')
  async findAll(@Ip() ip: any): Promise<responseCactchaCode> {
    const result = await this.codeService.findAll(ip);
    return { data: { svg: result.svg, key: result.key } };
  }
}
